Strongname Signing IKVM PDFBox for Word Addin - pdfbox

for a Word Addin I am using PDFBox to manipulate PDFs. Or rather I would like to use it. I used it before with a self-created Desktop App. PDFBox is a Java Library that can be made usable as DLLs with IKVM (like here: http://www.squarepdf.net/pdfbox-in-net ). The problem that I experience is that all libraries for Wordaddins must be strongnamed. I tried to strongname sign but then I get an exception that a part of apache common logging (in directory MANIFEST.MF) cannot be found.
I know this is pretty vague so far and I will post more details later on, but maybe someone already went through this and has an idea on how to do this right or can point me to some place where there is already a strongnamed version of PDFBox.
Thanks in advance!

I will give some more information to this question, because my colleague is in holiday. I have strong named all pdfbox-dlls and on the try to open a pdf, i will get the first FileNotFoundException. The File $(PrjectDir)\bin\x86\Debug\commons-logging.properties could not be found.
All following Exceptions has the same problem. As a sample the next exception is a DirectoryNotFoundException. It could not find \bin\x86\Debug\META-INF\services\org.apache.commons.logging.LogFactory . There are more than 10 FileNotFoundExceptions only at the opening of my PDF:
doc = PDDocument.load(new File(inputFile));
All of Them can't find something of the Logger.
In the next Step, i try to make a content Stream from the first page of that pdf:
contentStream = new PDPageContentStream(doc, (PDPage)doc.getDocumentCatalog().getAllPages().get(0), true, false);
The first Exception, i will become there is another FileNotFoundException for C:\Users(user).accessibility.properties or $(ProjectDir)\bin\x86\Debug\META-INF\services\java.text.spi.NumberFormatProvider
Until this point, i have 20 Exceptions or so. The most of them can't find something of the logger. But i can write the opened pdf to the harddisk. If i try to insert some text into contentstream, i get a harder Exception at the point i have to set the font:
PDFont font = PDType1Font.HELVETICA;
contentStream.setFont(font, 10);
At this point i get following Exception:
An exception (first chance) of type "System.TypeInitializationException" occurred in fontbox-1.8.12.dll.
Additional information: The type initializer for "org.apache.fontbox.cmap.CMap" generated an exception.
I think the references has a problem, if pdfbox is strong named. Has anybody an idea, what is to do? Thank you very much.

Related

Exception: Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed in serialize() (line 14

I am using the latest update of Drupal 9. For some reason when I install any NEW module that involves uploading images, It goes through the motions of uploading but does not save image. The images don't show up on the content from the module. And when I go back to look at it, the image is blank like I never uploaded an image. So I checked my error logs.
Here is the error in the log:
Exception: Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed in serialize() (line 14 of /home/xxxxxx/public_html/xxxxxxxx/core/lib/Drupal/Component/Serialization/PhpSerialize.php).
How do I fix this?
I tried asking drupal forums, No answer. I tried google. Nothing helped. I'm not that familiar with serialization.

iTextSharp.text.Image.GetInstance changes Request.MapPath

I've been stuck on this problem all night. I've looked everywhere and can't seem to find anything related to my exact problem. On our IIS server we have a page that creates a pdf. We put an image in the header of the created PDF. This had been working properly until last night when we updated some unrelated code on different pages. Now when we try to create the PDF we get an error that the image file doesn't exist. Here's the weird part, iTextSharp.text.Image.GetInstance is changing the path we send to it?
Here's the line of code
Dim oImage As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Request.MapPath("~/images/" & sLogo))
If we output the results of Request.MapPath("~/images/" & sLogo) we receive
E:\Inetpub\sitename\images\logo.jpg
When we place it in in the iTextShart.text.Image.GetInstance() function our path output changes to
C:\Windows\SysWOW64\inetsrv\images\defaultlogo.jpg
You can see the logo itself changes too, it should be noted that we do use DefaultLogo.jpg in the case that a client doesn't use their own logo but all the ones i'm testing with do. The path E:\Inetpub\sitename\images does exist and logo.jpg does exist.
Here's the weirdest part, if i change the path from images to image
IE: iTextSharp.text.Image.GetInstance(Request.MapPath("~/image/" & sLogo))
the output will be
E:\Inetpub\sitename\image\logo.jpg
So i have no idea why images doesn't resolve.
Any help is greatly appreciated, and if this answer has been posted before and i just can't find it i'm very sorry, and if you could point me to that i would appreciate that as well.
I figured out my issue, and it's sheer stupidity on my part. The page we call to create the pdf had bad security on it. Basically we were looking for a session variable that didn't exist and redirected that page to a session time out notice. Removed that session check and it's working now!

Can't get PDFBox CreatePDFA example to work - Color profile not found

I'm trying to get the example for creating a PDF/A document with Apache PDFBox up an running (CreatePDFA.java).
For this I copied the example class as is into a project module that includes a maven-dependency on PDFBox in version 2.0.0-RC3. I only changed the method signature and used a fixed font, filename and message instead of args[].
When trying to run the code I get an NPE in Line 107 because it cant't load the color profile (InputStream is null) When I check the included library in the project details I can see the resources folder, but it does not contain the expected file, namely "pdfa/sRGB Color Space Profile.icm".
Unfortunately, google-ing the problem only turned up more references to always the same example implementation, but after a while I acutally found what seems to be the needed file on apache.googlesource.com
I copied the file to our own resource directory and then used this line of code instead:
InputStream colorProfile = CreatePdfA.class.getResourceAsStream("/pdfa/sRGB Color Space Profile.icm");
This finally stopped the NPE - the file is apparently found - but now I get another exception which says:
java.lang.IllegalArgumentException: Invalid ICC Profile Data
Here, I'm stuck. I had hoped that this would work just out of the box, but it seems like I am missing something. Any ideas?
You already answered one part of the problem yourself: put the file into your resource directory.
The second problem may be a bad repository mirror or a transfer problem (binary to ascii). Here's the official repository URL with the ICC profile from the example:
https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/resources/org/apache/pdfbox/resources/pdfa/

pdfbox Font TrueType cause stripper.getText() error

I have some pdf need to extract to text
only one pdf is truetype
and it cause following error :
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.fontbox.ttf.TrueTypeFont.getAdvanceWidth(I)I
at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.getFontWidth(PDTrueTypeFont.java:677)
at org.apache.pdfbox.pdmodel.font.PDSimpleFont.getFontWidth(PDSimpleFont.java:231)
at org.apache.pdfbox.util.PDFStreamEngine.processEncodedText(PDFStreamEngine.java:411)
at org.apache.pdfbox.util.operator.ShowText.process(ShowText.java:45)
at org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:557)
at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:268)
at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:235)
at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:215)
at org.apache.pdfbox.util.PDFTextStripper.processPage(PDFTextStripper.java:460)
at org.apache.pdfbox.util.PDFTextStripper.processPages(PDFTextStripper.java:385)
at org.apache.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:344)
at org.apache.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:257)
I check the api source code and still can't get through it.
Is there something I can do?
or the 2.0 version solve this problem.
It's not an big issue but some tiny mistake
Thanks to mkl and Tilman Hausherr
It's only buildpath problem.
First , I have muti versions of fontbox that I didn't aware of.
Just check it again and check it hard !
If others have same error, check the dependencies
pdfbox-1.x.x.jar
fontbox-1.x.x.jar
they need to be the same!

pygame2exe "Runtime Error! This application has requested the Runtime to terminate it in an unusual way..."

I've started making a game using python and pygame, and tried using py2exe. It didn't work, (like it should), so I used the pygame2exe code found here: http://www.pygame.org/wiki/Pygame2exe
It still doesn't work, and comes up with the error stated in the title. I have a suspicion it's to do with not having the correct dlls, but I'm clueless apart from that.
Also, I managed to create a pygame executable in what I think was exactly the same way a few months ago, but now it doesn't work. If you'd like me o add a little more info I'd be happy to.
Here's a screenshot of the error message (I can't post images yet):
I've met the same problem and I finally solved it. The problem is with my font definition:
basicFont = pygame.font.SysFont(None, 48)
overFont = pygame.font.SysFont('Comic Sans MS', 60)
Using a default font to replace 'None' in your definition and add '.ttf' files in your dist folder can help