• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Issue with Creating a PDF from Url using .Net in localhost (Adobe Services API)

New Here ,
Dec 24, 2021 Dec 24, 2021

Copy link to clipboard

Copied

 

Hello,

I am using the virtually standard code below to create a PDF from Url.  

It is working perfectly when the targetUrl is my app in production (https://ffpro.ca/index) but failing at FileRef.CreateFromURI with an ServiceApiException when the targetUrl is my localhost (https://localhost:xxxxx/index )

Am I missing something? My Service Account credentials are clearly ok for production.  I suspect that Adobe does not have access to my localhost but I don't know what to do to make this work in my development environment.   I tried to disable Norton 360 or safe browser protection without success. 

Any suggestion?

Thanks in advance

Jean-Philippe

 

ConfigureLogging();

try
{
// Initial setup, create credentials instance.
Credentials credentials = Credentials.ServiceAccountCredentialsBuilder()
.FromFile(Directory.GetCurrentDirectory() + "/pdfservices-api-credentials.json")
.Build();

 

//Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
CreatePDFOperation htmlToPDFOperation = CreatePDFOperation.CreateNew();

 

// Set operation input from a source URL.
//FileRef source = FileRef.CreateFromURI(new Uri("https://ffpro.ca/index"));  // Working properly
FileRef source = FileRef.CreateFromURI(new Uri("https://localhost:xxxxx/index" ));  // Failing properlyhtmlToPDFOperation.SetInput(source);

 

// Provide any custom configuration options for the operation.
SetCustomOptions(htmlToPDFOperation);

 

// Execute the operation.
FileRef result = htmlToPDFOperation.Execute(executionContext);

 

// Save the result to the specified location.
string targetFile = Directory.GetCurrentDirectory() + "/wwwroot" + PDFReportPathName+PDFReportFileName;

result.SaveAs(targetFile);
}
catch (ServiceApiException ex)
{
log.Error("Exception encountered while executing operation", ex);}

...

 

TOPICS
PDF Services API

Views

357

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 11, 2022 Feb 11, 2022

The Adobe server needs access to a public URL. You won't be able to use localhost. If you need to generate PDF from HTML and alsio need to have a local dev environment, I recommend zipping the HTML payload and sending it using that method.

Votes

Translate

Translate
Community Expert ,
Feb 11, 2022 Feb 11, 2022

Copy link to clipboard

Copied

The Adobe server needs access to a public URL. You won't be able to use localhost. If you need to generate PDF from HTML and alsio need to have a local dev environment, I recommend zipping the HTML payload and sending it using that method.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 11, 2022 Feb 11, 2022

Copy link to clipboard

Copied

LATEST

Thank you very much Joel for your reply and suggesstion. It makes a lot of sense.

I actually decided to use the converter from html to pdf from Syncfusion, one of my existing provider. I did not realize initially that they had such a service. I was able to implement both in my local environment and Azure production environment.

Thanks again!

Jean-Philippe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources