We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problems with PdfFileMend

Hi everyone,

I can't seem to get this piece of code to work.

It breaks on the first line saying:
System.NotSupportedException: The given path's format is not supported.

Can someone help me?

Here is my code in vb.net:

Try
'create PdfFileMend object to add text
Dim mender As New PdfFileMend("‪C:\PDFS\formtest.pdf", "‪C:\PDFS\formtest2.pdf")

'create formatted text
Dim addtext As New FormattedText(text, metextcolour, metextbkcolour, mefontname, EncodingType.Winansi, True, mefontsize)

'set whether to use Word Wrap or not and using which mode
mender.IsWordWrap = True
mender.WrapMode = WordWrapMode.Default

'add text in the PDF file
mender.AddText(addtext, pageno, lowerleftX, lowerleftY)

'close PdfFileMend object
mender.Close()

Return "Success"
Catch ex As Exception
Return "Fail: " + ex.ToString()
End Try

Hi William,


Thanks for your inquiry. I am afraid I am unable to notice any issue while testing the scenario with a sample PDF document using Aspose.Pdf for .NET 8.8.0. Can you please share your sample document here? So we will look into it and will provide you more information accordingly.

We are sorry for the inconvenience caused.

Best Regards,

Hello,


I have attached the PDF, and I have attached the source (without the license).

It doesn’t seem to work my end, hopefully you can help me get it working.

Kind Regards,
William

Hi William,


Thanks for sharing the details.

I have tested the scenario and I am able to
notice the same problem. For the sake of correction, I have logged this problem
as PDFNEWNET-36220 in our issue tracking system. We will further
look into the details of this problem and will keep you updated on the status
of correction. Please be patient and spare us little time. We are sorry for
this inconvenience.

Hi Nayyer Shahbaz,


I understand you are busy and I don’t want to be a pain but we really need this functionality soon.
How long would you suggest this issue will take to resolve?

If it will take a long time to fix is there another way to get it working or another way around it?

Thanks for your time,
Kind Regards,
William

Hi William,


Thanks for your feedback. Please try DOM approach to add text in existing PDF file, hopefully it will help you to accomplish your requirement. Please check following document link for code snippet and details. Moreover, we will keep you updated about the original issue progress via this forum thread.


Please feel free to contact us for any further assistance.

Best Regards,

That is brilliant thank-you.

I have got it working and it works perfectly fine :slight_smile:

I think I found a bug with it however. It doesn’t seem to work with landscape PDFs.
At the moment it doesn’t really matter to us because we don’t deal with landscape PDFs at the moment, however I thought you might like to know about the bug in-case we or anybody else would like to use this method in editing PDFs that are landscape and not portrait in the future.

Kind Regards,
William

Hi William,


Thanks for sharing the details.

I have tested the scenario using following code snippet and I am unable to notice any problem. The text is properly being added and PDF file is appearing in LandScape orientation. Can you please share some sample PDF files causing problem at your end so that we can further investigate this problem. We are sorry for this inconvenience.

[C#]

//Open document<o:p></o:p>

Document pdfDocument = new Document();

pdfDocument.PageInfo.IsLandscape = true;

//Get particular page

Page pdfPage = pdfDocument.Pages.Add();// (Page)pdfDocument.Pages[1];

//Create text fragment

TextFragment textFragment = new TextFragment("main text");

textFragment.Position = new Position(100, 600);

//Set text properties

textFragment.TextState.FontSize = 12;

textFragment.TextState.Font = FontRepository.FindFont("TimesNewRoman");

textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray);

textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red);

//Create TextBuilder object

TextBuilder textBuilder = new TextBuilder(pdfPage);

//Append the text fragment to the PDF page

textBuilder.AppendText(textFragment);

//Save document

pdfDocument.Save(“c:/pdftest/LandScapeText_output.pdf”);

Sorry this is my fault.
I forgot to put in the line:
pdfDocument.PageInfo.IsLandscape = true
And change the y coordinate.

Ignore that previous comment.
Thanks for helping me out once again and this is brilliant!

Hi William,


We are glad to hear that your problem is resolved. Please continue using our products and in the event of any further query, please feel free to contact.

The issues you have found earlier (filed as PDFNEWNET-36220) have been fixed in Aspose.Pdf for .NET 9.7.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi William,


We have further investigated the above reported issue and found that The code snippet contains invisible special characters in string objects. Please use following code snippet with fixed strings, it will help you to accopmlish the task.


'create PdfFileMend object to add
text
<o:p></o:p>

Dim mender As New PdfFileMend()

mender.BindPdf("C:\pdftest\formtest.pdf")

'create formatted text

Dim addtext As New FormattedText("Hello World!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, True, 14)

'set whether to use Word Wrap or not and using which mode

mender.IsWordWrap = True

mender.WrapMode = WordWrapMode.Default

'add text in the PDF file

mender.AddText(addtext, 1, 100, 100)

'close PdfFileMend object

' mender.Close()

mender.Save("C:\pdftest\formtest2.pdf")


Please feel free to contact us for any further assistance.


Best Regards,