Comments (5)
Here is tested solution. Works for me.
here is only explanation for 'gsapi_run_string'. -> change all strings under 'gsapi'.
The same approach works for string[] under 'gsapi_init_with_args'. -> use IntPtr[] for argv.
Instead calling 'gsapi_run_string' use 'call_gsapi_run_string(string str)' provided here.
// ====================================================
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate int gsapi_run_string(IntPtr instance, IntPtr str, Int32 user_errors, out Int32 pexit_code);
// ============================================
public int call_gsapi_run_string(IntPtr _gs_instance, string str, out int exit_code)
{
var pArg = StringHelper.NativeFromString(str);
int rc_run;
try
{
rc_run = gsapi_run_string(_gs_instance, pArg, 0, out exit_code);
}
finally
{
StringHelper.releaseManagedPointer(pArg);
}
return rc_run;
}
// ===========================================
public static IntPtr NativeUtf8FromString(string managedString)
{
//var buffer = System.Text.Encoding.UTF8.GetBytes(managedString);
int len = Encoding.UTF8.GetByteCount(managedString);
byte[] buffer = new byte[len + 1];
Encoding.UTF8.GetBytes(managedString, 0, managedString.Length, buffer, 0);
IntPtr nativeUtf8 = Marshal.AllocHGlobal(buffer.Length);
Marshal.Copy(buffer, 0, nativeUtf8, buffer.Length);
return nativeUtf8;
}
// ===========================================
public static void releaseManagedPointer(IntPtr managedPointer)
{
Marshal.FreeHGlobal(managedPointer);
}
// ===========================================
happy coding.
from ghostscript.net.
Hi,
In the subject you say "filename" and then later "title". Do you think it's the issue in the filename or pdf content?
What native Ghostscript library version do you use?
What Ghostscript.NET version do you use?
Can you post problematic PDF somewhere so I can see what's wrong?
from ghostscript.net.
Hi
Thank you for your answer.
I meant filename in both cases, sorry for the confusion.
I'm using the last version of ghostscript (9.15) in 32 bits version and the last version of Ghostscript.Net (1.1.9.0).
It's not a problematic pdf, if I change the filename by replacing the ê by e then it works whithout any issue. If I put a ê in the filename of any pdf then I have the issue.
It also crash with other special characters, not only ê.
It seems I'm not the only one, I've seen the same issue on codeplex : https://ghostscriptnet.codeplex.com/workitem/2266
from ghostscript.net.
I found a simple workaround for my issue. I copy the file in the user's temp folder with a random name and it works with any pdf (all the problematic ones I tried at least).
string pdfCopyPath = Path.GetTempPath() + Path.GetRandomFileName() + ".pdf";
File.Copy(pdfPath, pdfCopyPath);
from ghostscript.net.
Still doesn't work (with the latest versions of gs and Ghostscript.NET)...
from ghostscript.net.
Related Issues (20)
- Is it possible to print user controls with ghostscript?
- Unable to Convert Pdf to Png Using Ghostscript.Net Visual Studio 2022 HOT 2
- Converting PDF pages to images (new PDF interpreter problem) HOT 1
- Missing elements/colors when converting PDF to image
- GhostscriptRasterizer.GetPage returns null when using gs.9.56.1 (current version as of Aug 15, 2022) HOT 3
- it
- GhostscriptPngDevice e CustomDllPath
- Error: "'gsapi_init_with_args' is made -100" with long filename and Asian language HOT 1
- GhostscriptRasterizer.GetPage Setting DPI has no impact on the resulting raster
- Attached pdf file raises a System.AccessViolationException HOT 1
- Is it possible to use Stream in Ghostscript.Net and how to reduce pdf size?
- Module could not be loaded HOT 1
- Everything bold and blurred HOT 5
- Ghostscript command to FLATTEN ANNOTATIONS but keep HYPERLINKS alive HOT 9
- Ghostscript - completely REMOVE METADATA from pdf files HOT 5
- -dPreserveAnnotTypes NOT Working HOT 3
- Ghostscript - completely REMOVE METADATA from pdf files 2 HOT 2
- Ghostscript Nuget Package HOT 1
- Random App Pool crashes HOT 3
- Silently Print HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ghostscript.net.