Declined
Last Updated: 09 Dec 2021 07:26 by ADMIN
Anoosh
Created on: 29 Jan 2021 19:03
Category: PdfProcessing
Type: Bug Report
1
using PdfFormatProvider() to load a simple PDF. I am getting the error import not supported:

I have read that there limitations to PDF files being imported, however, the file being imported  was generated with FixedContentEditor, so, should be able to import?

  using (Stream stream = Stream)
        {
          try
          {
            this._document = provider.Import(stream);
            _InputPath = fileName;
          }
          catch (Exception e)
          {
            Errors = "Could not open file " + fileName + ": " + e.Message;
            this._document = null;
          }
        }
      }
7 comments
ADMIN
Dimitar
Posted on: 09 Dec 2021 07:26

Hi Anoosh,

I am glad that this works now. Do not hesitate to contact us if you have other questions.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Anoosh
Posted on: 09 Dec 2021 01:26
This was resolved thanks for the answer. Also see Ticket ID: 1545482
ADMIN
Dimitar
Posted on: 07 Dec 2021 11:58

Hello Anoosh,

You cannot use the WordsProcessing library to merge the PDF files. Currently, the WordsProcessing library support conversion to PDF from other file formats, but PDF files cannot be imported. 

To merge the PDF files you can use the PdfProcessing library and more specifically the PDFStreamWriter. An example of this is available in our SDK repository: document-processing-sdk/PdfProcessing/PdfStreamWriterPerformance at master ยท telerik/document-processing-sdk

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Anoosh
Posted on: 07 Dec 2021 05:20

I am running into the same issue again.  If this thread is closed, I will open a new one.

I am writing a quick method to merge several PDFs:

 public string Merge(string OutputPath, List<string> MergeFilePaths, out string Errors)
        {
            Errors = null;
            DocumentConverter Converter = new DocumentConverter();
            if (!string.IsNullOrEmpty(Errors))
                return null;
            string TempDir = Utils.GetTempDir();
            PdfFormatProvider PdfFormatProvider = new PdfFormatProvider();
            RadFlowDocument MergeIntoDocument = new RadFlowDocument();
            foreach (string OnePath in MergeFilePaths)
            {
                string ConvertedPath = Converter.ConvertFileIfNecessary(OnePath, "pdf", out Errors);
                ConvertedPath = ConvertedPath.Replace("\\", "/").Replace(TempDir, "/MedusaTemp");  // Make virtual
                if (!string.IsNullOrEmpty(Errors))
                    return null;
                using (Stream OnceStream = File.OpenRead(ConvertedPath))
                {
                    RadFlowDocument OneDocument = PdfFormatProvider.Import(OnceStream);
                    MergeIntoDocument.Merge(OneDocument);
                }
            }
            File.WriteAllBytes(OutputPath, PdfFormatProvider.Export(MergeIntoDocument));
            return OutputPath;
        }

Given my past experience, I am converting paths to virual, even though not sure why it matters as PdfFormatProvider is importing from a stream.  I still get "'Import not supported." when PdfFormatProvider.Import(OnceStream)

Example of the path value in absolute and virtual is:

ConvertedPath "/MedusaTemp/Test.pdf" string
System.Web.Hosting.HostingEnvironment.MapPath(ConvertedPath) "C:\\MedusaTemp\\Test.pdf" string

The stream that is opened looks good and has correct length.  

What am I missing?

 

 

ADMIN
Dimitar
Posted on: 13 Apr 2021 07:03

Hello Anoosh,

I am glad that you have found the solution to your case. Do not hesitate to contact us if you have other questions.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Anoosh
Posted on: 12 Apr 2021 17:38
Looks like the issue was the file location.  PDF processing requires the path to be in the same directory structure as the website. Solved by creating a virtual directory pointing to the actual file directory.
ADMIN
Dimitar
Posted on: 01 Feb 2021 11:17

Hi Anoosh,

You should be able to import a file created with our library. Can you send me the file and the code that you have used to generate it? This will allow me to properly investigate this case and determine what is causing such issues.

Please note that this is a public tread and the file will be seen by other users as well. If there is confidential information in the file please open a new support ticket and attach it there. 

I am looking forward to your reply.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.